import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'

// 二级的设置路由标题meta：title 三级的设置分类标题meta：title和classifytitle
const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    redirect: '/login',
  },
  // 登录
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/login/index.vue')
  },
  // 首页
  {
    path: '/home',
    name: 'home',
    component: () => import('../views/index.vue'),
    // 二级
    children:[
      // 数据统计
      {
        path: '/echarts',
        name: 'echarts',
        component: () => import('../views/HomeChildren/EchartsView.vue'),
        meta:{
          title:'数据展示'
        }
      },
      // 权限列表
      {
        path: '/permissionlist',
        name: 'permissionlist',
        component: () => import('../views/HomeChildren/PermissionList.vue'),
        meta:{
          title:'权限列表'
        }
      },  
      // 用户
      {
        path: '/user',
        name: 'user',
        component: () => import('../views/HomeChildren/UserOne.vue'),
        redirect:'/home/user/userlist',
        meta:{
          title:'住户信息'
        },
        // 三级
        children:[
          // 列表展示
          {
            path: '/userlist',
            name: 'userlist',
            component: () => import('../views/HomeChildren/UserList.vue'),
            meta:{
              title:'住户信息',
              classifyTitle:'住户信息展示'
            }
          },
          // 列表修改
          {
            path: '/userupdate',
            name: 'userupdate',
            component: () => import('../views/HomeChildren/UserUpdate.vue'),
            meta:{
              title:'住户信息',
              classifyTitle:'住户信息更新'
            }
          }
        ]
      },
    ]
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
